#ifndef VIDEOSENDER_H
#define VIDEOSENDER_H

#include "IniHandle/IniHandleApi.h"

#include <iostream>
#include <string>
#include <QWidget>
#include <QTimer>
#include <QSlider>
#include <QListWidget>
#include <QPushButton>
#include <QIcon>


#include "playerwidget.h"

//QT_BEGIN_NAMESPACE
//namespace Ui { class VideoSender; }
//QT_END_NAMESPACE


//udp info struct
#include <QResizeEvent>
#include <stdio.h>
#include <list>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>

#include <iostream>
#include <cstdio>
#include <time.h>

#include "piccache.h"
#include <QDir>
#include <QDebug>
#include <QPixmap>
#include <QFile>
#include <QFileDialog>
#include <string>

//qt window

class LocalPlayer : public QWidget
{
    Q_OBJECT

public:
    LocalPlayer(QWidget *parent = nullptr);
    ~LocalPlayer();

    void init();
    void ShowImage(cv::Mat& mat);
    QImage MatToQImage2(const cv::Mat &mat);


signals:
    void resizeSendPicLabel(int width,int height);

private slots:
    //void on_pushButton_open_clicked();
    void imgUpdate();
    void msgUpdate();

    void on_pushButton_play_clicked();

    void on_timeSlider_sliderMoved(int position);


protected:
    void resizeEvent(QResizeEvent *event) override{
        int width=event->size().width();
        int height=event->size().height();
        emit this->resizeSendPicLabel(width,height);
    }

private:
    int fps;
    int fpsCount;

    QTimer *videoTimer;
    QTimer *msgTimer;

    //houlc playerWidget
    PlayerWidget *playerWidget;

    //houlc button
    QPushButton *playButton;

    QSlider *timeSlider;



    //houlc piccache
    PicCache *picCache;
    int updateCount;
    QDir *dir;
    QFile *infoFile;
    bool playFlag, endFlag;
    QPixmap red, gray, arrow;
    QPixmap pp_play, pp_pause;
    QFont numFont;
    QString matStr;
    QString dirStr;

    QPixmap backimg;
    bool show_backimg;

    int update_interval_ms;
    std::string picture_input_dir;
};
#endif // VideoSender_H
